﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using DAL;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using mahoavb;


public partial class MasterPage : System.Web.UI.MasterPage
{
    GetData getData;
    protected void Page_Load(object sender, EventArgs e)
    {
        LoadData();
        CheckSession();
        LoadSoSanPham();
        LoadNSX();
    }


    public void LoadSoSanPham()
    {
        List<NewCart> listNewCart = (List<NewCart>)Session["Cart"];
        if (listNewCart != null)
        {
            lblTolTalSanPham.Text = listNewCart.Count().ToString();
        }
        else
        {
            lblTolTalSanPham.Text = "0";
        }
    }

    public void LoadNSX()
    {
        getData = new GetData();
        DataListNSX.DataSource = getData.LoadLoaiNSX();
        DataListNSX.DataBind();
    }
    public void LoadData()
    { 
        getData = new GetData();
        DataListLoaiSP.DataSource = getData.LoadLoaiSP();
        DataListLoaiSP.DataBind();
    }

    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {

    }

    public void CheckSession()
    {
        if (Session["MaKh"] != null && Session["MaKh"] != "")
        {
            //lblregionLogin.Visible = true;
            lbleTenDangNhap.Text = Session["UserLogin"].ToString();
            //lblDangNhap.Visible = false;
            //lblDangKy.Visible = false;
            lbleDoiMaKhau.Visible = true;
        }
        else
        {
            //lblDangNhap.Visible = true;
            //lblDangKy.Visible = true;
            lbleDoiMaKhau.Visible = false;
        }
    }
    protected void LinkButton1_Click(object sender, EventArgs e)
    {
        Session.Abandon();
        Session.RemoveAll();
        Response.Redirect("TrangChu.aspx");
    }
    protected void ImageButton1_Click1(object sender, ImageClickEventArgs e)
    {
        string tenSP = TextBox1.Text.Trim();
        Response.Redirect("TimKiem.aspx?TenSp=" + tenSP);
    }
}
